package com.eqxiu.ieditor.api.controller.scene;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.eqxiu.ieditor.api.HomePageSceneServiceApi;
import com.eqxiu.ieditor.api.HomePageUserServiceApi;
import com.eqxiu.ieditor.dto.HomePageUserDTO;
import com.eqxiu.ieditor.dto.HomePageUserSceneDTO;
import com.eqxiu.ieditor.interceptor.UserContext;
import com.eqxiu.mall.marketing.api.MarketComponentSceneRelApi;
import com.eqxiu.scene.dto.SceneDTO;
import com.eqxiu.user.api.UserApi;
import com.eqxiu.user.api.dto.User;
import eqxiu.passport.sdk.dto.UserDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.eqxiu.ieditor.api.controller.BaseApiController;
import com.eqxiu.ieditor.api.controller.scene.doc.SceneApiDoc;
import com.eqxiu.ieditor.commons.web.ResultData;
import com.eqxiu.scene.api.SceneServiceApi;

@RestController
@RequestMapping("/api/scene")
@Api(description = "场景相关操作", tags = "scene")
public class SceneApiController implements SceneApiDoc, BaseApiController {
    @Autowired
    private SceneServiceApi sceneServiceApi;

    @PostMapping("/loadPages")
    @Override
    public ResultData getPages(@RequestParam("pageIds[]") List<Long> pageIds) {
        List<ScenePagePair> list = pageIds.parallelStream().map(
                pageId -> {
                    return new ScenePagePair(pageId, sceneServiceApi.getPage(pageId));
                }
        ).collect(Collectors.toList());

        return success().setList(list);
    }


}
